package gam.n1.e.a;

import gam.n1.e.CancellableEvent;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Predicate;

public class AreaSpawnEntityEvent extends CancellableEvent {
    private Entity spawnEntity;
    public AreaSpawnEntityEvent(@NotNull Entity entity){
        this.spawnEntity = entity;
    }

    public Entity getSpawnEntity() {
        return spawnEntity;
    }

    public boolean setSpawnEntity(Entity spawnEntity,Predicate<Entity> condition) {
        Objects.requireNonNull(condition);
        Objects.requireNonNull(spawnEntity);
        if (condition.test(spawnEntity)) {
            this.spawnEntity = spawnEntity;
            return true;
        }
        return false;
    }
}
